package scau.gsmg.misp.vo;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * SaleReturn entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "sale_return", catalog = "misp")
public class SaleReturn implements java.io.Serializable {

	// Fields

	private Integer id;
	private User user;
	private SaleOrder saleOrder;
	private String saleReturnId;
	private Double total;
	private Integer amount;
	private Timestamp createTime;
	private Set<SaleReturnItems> saleReturnItemses = new HashSet<SaleReturnItems>(
			0);

	// Constructors

	/** default constructor */
	public SaleReturn() {
	}

	/** minimal constructor */
	public SaleReturn(User user, SaleOrder saleOrder, String saleReturnId,
			Double total, Integer amount, Timestamp createTime) {
		this.user = user;
		this.saleOrder = saleOrder;
		this.saleReturnId = saleReturnId;
		this.total = total;
		this.amount = amount;
		this.createTime = createTime;
	}

	/** full constructor */
	public SaleReturn(User user, SaleOrder saleOrder, String saleReturnId,
			Double total, Integer amount, Timestamp createTime,
			Set<SaleReturnItems> saleReturnItemses) {
		this.user = user;
		this.saleOrder = saleOrder;
		this.saleReturnId = saleReturnId;
		this.total = total;
		this.amount = amount;
		this.createTime = createTime;
		this.saleReturnItemses = saleReturnItemses;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "sale_order_id", nullable = false)
	public SaleOrder getSaleOrder() {
		return this.saleOrder;
	}

	public void setSaleOrder(SaleOrder saleOrder) {
		this.saleOrder = saleOrder;
	}

	@Column(name = "sale_return_id", nullable = false, length = 40)
	public String getSaleReturnId() {
		return this.saleReturnId;
	}

	public void setSaleReturnId(String saleReturnId) {
		this.saleReturnId = saleReturnId;
	}

	@Column(name = "total", nullable = false, precision = 11, scale = 1)
	public Double getTotal() {
		return this.total;
	}

	public void setTotal(Double total) {
		this.total = total;
	}

	@Column(name = "amount", nullable = false)
	public Integer getAmount() {
		return this.amount;
	}

	public void setAmount(Integer amount) {
		this.amount = amount;
	}

	@Column(name = "createTime", nullable = false, length = 19)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "saleReturn")
	public Set<SaleReturnItems> getSaleReturnItemses() {
		return this.saleReturnItemses;
	}

	public void setSaleReturnItemses(Set<SaleReturnItems> saleReturnItemses) {
		this.saleReturnItemses = saleReturnItemses;
	}

}